package com.example.mysqltry.controller;

import com.example.mysqltry.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;


@RestController
public class JdbcController {
    @Autowired
    private JdbcTemplate jdbcTemplate;
//    public List<Books> findAll()
//    { return  jdbcTemplate.query("select * from Books",new BeanPropertyRowMapper<>(Books.class));
//    };
    @GetMapping("/findAll")
    public List<Map<String, Object>>findAll()
    { return  jdbcTemplate.queryForList("select * from tb_newbee_mall_admin_user");

    }

//    @GetMapping("/finduser")
//    public List<User>findUser()
//    { return  jdbcTemplate.query("select * from user",new BeanPropertyRowMapper<>(User.class));
//
//    }

}
